package com.zh.work.controller.platform.merch;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zh.common.entity.JSONResult;
import com.zh.work.entity.merch.ChangeMerchAccountEntity;
import com.zh.work.entity.merch.ChangeMerchInfoEntity;
import com.zh.work.entity.merch.ChangeMerchRateEntity;
import com.zh.work.service.platform.merch.ChangeMerchInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @Description: 商户资料变更记录管理
 * @Author: Li.HuiNeng
 * @Create in: 2019/09/05
 * @Version: 1.0.1
 */
@Api(value = "商户资料变更记录管理控制器", produces = "application/json", tags = {"商户资料变更记录管理控制器"})
@RestController
@RequestMapping("/changeMerch")
public class ChangeMerchInfoController {

    /**
     * @Description: 有业务逻辑需要处理时使用
     * ------------------------
     * @Author: Li.HuiNeng
     * @Date: 2019/09/05
     */
    @Autowired
    private ChangeMerchInfoService service;


    @ApiOperation(value = "分页查询商户基础资料变更记录数据集", tags = {"getPagesChangeMerchInfos"}, notes = "分页查询商户基础资料变更记录数据集")
    @GetMapping("/getPagesChangeMerchInfos")
    public JSONResult<List<ChangeMerchInfoEntity>> getPagesChangeMerchInfos(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name = "pageNo") Integer pageSize,
            @ApiParam(value = "商户资料变更记录实体类", name = "changeMerchInfoEntity") ChangeMerchInfoEntity changeMerchInfoEntity) {
        JSONResult<List<ChangeMerchInfoEntity>> jsonResult = new JSONResult<>();
        try {
            IPage<ChangeMerchInfoEntity> result = this.service.selectChangeMerchPages(new Page<>(pageNo, pageSize), changeMerchInfoEntity);
            jsonResult.setTotal(result.getTotal());
            jsonResult.setData(result.getRecords());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        } catch (Exception e) {
            jsonResult.setMessage(e.getLocalizedMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return jsonResult;
    }

    @ApiOperation(value = "分页查询商户费率变更记录数据集", tags = {"getPagesChangeMerchRates"}, notes = "分页查询商户费率变更记录数据集")
    @GetMapping("/getPagesChangeMerchRates")
    public JSONResult<List<ChangeMerchRateEntity>> getPagesChangeMerchRates(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name = "pageNo") Integer pageSize,
            @ApiParam(value = "商户资料变更记录实体类", name = "changeMerchRateEntity") ChangeMerchRateEntity changeMerchRateEntity) {
        JSONResult<List<ChangeMerchRateEntity>> jsonResult = new JSONResult<>();
        try {
            IPage<ChangeMerchRateEntity> result = this.service.selectChangeMerchPages(new Page<>(pageNo, pageSize), changeMerchRateEntity);
            jsonResult.setTotal(result.getTotal());
            jsonResult.setData(result.getRecords());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        } catch (Exception e) {
            jsonResult.setMessage(e.getLocalizedMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return jsonResult;
    }

    @ApiOperation(value = "分页查询商户账户变更记录数据集", tags = {"getPagesChangeMerchAccounts"}, notes = "分页查询商户账户变更记录数据集")
    @GetMapping("/getPagesChangeMerchAccounts")
    public JSONResult<List<ChangeMerchAccountEntity>> getPagesChangeMerchAccounts(
            @ApiParam(value = "起始页", name = "pageNo") Integer pageNo,
            @ApiParam(value = "当前页显示数量", name = "pageSize") Integer pageSize,
            @ApiParam(value = "商户资料变更记录实体类", name = "changeMerchAccountEntity") ChangeMerchAccountEntity changeMerchAccountEntity) {
        JSONResult<List<ChangeMerchAccountEntity>> jsonResult = new JSONResult<>();
        try {
            IPage<ChangeMerchAccountEntity> result = this.service.selectChangeMerchPages(new Page<>(pageNo, pageSize), changeMerchAccountEntity);
            jsonResult.setTotal(result.getTotal());
            jsonResult.setData(result.getRecords());
            jsonResult.setMessage("操作成功");
            jsonResult.setSuccess(true);
            jsonResult.setCode(200);
        } catch (Exception e) {
            jsonResult.setMessage(e.getLocalizedMessage());
            jsonResult.setSuccess(false);
            e.printStackTrace();
        }
        return jsonResult;
    }
}
